package com.hxzy.facade.controller.store;

import com.github.pagehelper.PageInfo;
import com.hxzy.framework.common.resp.R;
import com.hxzy.module.store.api.store.StoreFeignApi;
import com.hxzy.module.store.api.store.req.StoreReq;
import com.hxzy.module.store.api.store.resp.StoreResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wy
 * @Description TODO
 * @Date 2024/1/24 16:13
 * @Version 1.0
 */
@RestController
@Api(tags = "总部后台-门店管理")
@RequestMapping("/storeManage")
public class FacadeStoreController {

    @Autowired
    private StoreFeignApi  storeFeignApi;

    @ApiOperation(value = "门店列表")
    @GetMapping(value = "/storeList")
    public R<PageInfo<StoreResp>> storeList(@Validated StoreReq req) {
        R<PageInfo<StoreResp>> r = this.storeFeignApi.storeList(req);
        return r;
    }

//    @Operation(summary = "门店列表")
//    @GetMapping(value = "/storeList")
//    public R<PageInfo<StoreResp>> storeList(@Validated StoreReq req) {
//        Map<String, Object> paramsMap = BeanUtil.beanToMap(req,false,true);
//
//        // http://localhost:8023/storeManage/storeList?key={key}&key2={key2}
//        StringBuffer url=new StringBuffer("http://store/storeManage/storeList");
//
//        R r=null;
//
//        //如果有参数
//        if(paramsMap.size()>0){
//            url.append("?");
//            for(String key : paramsMap.keySet()){
//              url.append(key).append("=").append("{").append(key).append("}").append("&");
//            }
//            //删除最后一个 &
//            url.deleteCharAt(url.length()-1);
//
//            //传递参数
//            r = restTemplate.getForObject(url.toString(), R.class, paramsMap);
//        }else{
//            r = restTemplate.getForObject(url.toString(), R.class);
//        }
//
//        return r;
//
//        //    Result<PageInfo<StoreResp>> pageInfoResult = storeFeign.storeList(req);
////        if (pageInfoResult.getCode() != ResultCode.SUCCESS.getCode()) {
////            throw new ApiException(500, pageInfoResult.getMsg());
////        }
//        //return R.success(pageInfoResult.getData());
//
//    }

}
